import java.util.Arrays;
import java.util.Scanner;
class NGuessNumber {

    public static int[] numbers = new int[4];
    public static int[] guesslist = new int[4];
    public static int a_num = 0;
    public static int b_num = 0;

    public static int[] main(String[] args) {
        System.out.println("新的猜数字游戏");

        while(true) {

            System.out.println("1开始游戏|");
            System.out.println("0退出游戏");
            Scanner sc = new Scanner(System.in);

            switch (sc.nextInt()) {
                case 0:
                    System.out.println("已退出游戏");
                    System.exit(0);
                    break;
                case 1:
                    int cs = 0;
                    int sy = 7;

                    System.out.println("已开始游戏\n");
                    generateAnswer();
                default:
                    System.out.println("错误的输入字符，请输入0/1\n");
            }
        }
    }

        public static int[] generateAnswer(){
            //随机生成4个0-9之间的不重复的整型数作为答案并返回的功能。
            int index = 0;

            while (true) {
                int random = (int) (Math.random() * 9 + 1);
                int j = 0;
                for (; j < numbers.length; j++) {
                    if (random == numbers[j]) {
                        break;
                    }
                }
                if (j == numbers.length) {
                    numbers[index++] = random;
                }
                if (index == 4) {
                    break;
                }
            }
            return numbers;


        }


    }
